#ifndef LC_IR_SENSOR_MT03X_H
#define LC_IR_SENSOR_MT03X_H

#include "util.h"
#include <stdbool.h>

#ifdef __cplusplus
extern "C"
{
#endif
    void sensor_mt03x_init(void);
    void sensor_mt03x_init_config(uint8_t *data, uint16_t length);
    void sensor_mt03x_common_handler(uint8_t *data, uint16_t length);
    bool sensor_mt03x_ok(void);
    bool sensor_mt03x_minsize_ok();
    bool sensor_mt03x_pos_ok();
    uint32_t sensor_mt03x_get_minisize(void);
    u8 *sensor_mt03x_get_query(uint32_t *size);
    u8 *sensor_mt03x_start(uint32_t *size);
    float sensor_mt03x_get_temp(void);
    uint32_t sensor_mt03x_get_calc_count();
    u8 *sensor_mt03x_get_setA(uint32_t *size, uint16_t cap_value);
    u8 *sensor_mt03x_get_setE(uint32_t *size, uint16_t value);

#define INIT_CMD_IIR_LENGTH (11)
#define INIT_CMD_MAVG_LENGTH (10)
#define INIT_CMD_LMODE_LENGTH (10)

#define INIT_CMD_IIR_VALUE (50)
#define INIT_CMD_MAVG_VALUE (1)
#define INIT_CMD_LMODE_VALUE (3)

#define INIT_CMD_TIMEOUT (3000)
#define INIT_CMD_REPLY_VALUE "ID="
#define INIT_CMD_REPLY_LENGTH (3)
    extern const u8 sensor_mt03x_CONFIG_INIT_IIR_CMD[INIT_CMD_IIR_LENGTH];
    extern const u8 sensor_mt03x_CONFIG_INIT_MAVG_CMD[INIT_CMD_MAVG_LENGTH];
    extern const u8 sensor_mt03x_CONFIG_INIT_LMODE_CMD[INIT_CMD_LMODE_LENGTH];

    extern volatile uint16_t m_sensor_mt03x_pos_x;
    extern volatile uint16_t m_sensor_mt03x_pos_y;
    extern volatile uint32_t mt03x_last_connect_time;

    extern uint16_t mt03x_version;
    extern uint8_t mt03x_LMode;
    extern uint8_t mt03x_RMode;
    extern uint8_t mt03x_iir;
    extern uint8_t mt03x_mavg;
    extern uint16_t mt03x_epsilon;

    extern uint16_t m_sensor_mt03x_otype;
    extern volatile float m_sensor_mt03x_ta;

    extern int m_sensor_mt03x_size_type;

#define COLOR_OUTPUT_TYPE_RGB888 0
#define COLOR_OUTPUT_TYPE_RGB565 1

#define SHOW_COLOR_OUTPUT_TYPE COLOR_OUTPUT_TYPE_RGB888
#ifdef __cplusplus
} /* extern "C" */
#endif

#endif
